import 'package:flutter/material.dart';
import 'package:robot3/services.dart';


void main() {
  runApp(MaterialApp(
    home: FanShapeWidget(),
  ));
}

class FanPainter extends CustomPainter {
  final  start= 180;
  final  end  =  90.0;
  @override
  void paint(Canvas canvas, Size size) {
    final paint = Paint()
      ..color = Colors.red.withOpacity(0.5)  // 设置扇形背景颜色为红色
      ..style = PaintingStyle.fill; // 填充扇形

    // 定义一个矩形框，用于限定圆弧的绘制范围
    Rect rect = Rect.fromCircle(center: Offset(size.width / 2, size.height / 2), radius: 100);
    // 创建路径并添加80度圆弧
    Path path = Path()
      ..moveTo(size.width / 2, size.height / 2) // 移动到圆心
      ..arcTo(rect, start * (3.14159 / 180), end * (3.14159 / 180), false)
    ; // 起始角度为0，扫过角度为90度
    // 绘制路径（扇形）
    canvas.drawPath(path, paint);
  }

  @override
  bool shouldRepaint(covariant CustomPainter oldDelegate) {
    return false; // We don't need to repaint as the shape doesn't change
  }
}

class FanShapeWidget extends StatelessWidget {
  @override
  Widget build(BuildContext context) {
    return Scaffold(
      body: Center(
        child: CustomPaint(
          size: Size(461/ratio, 416/ratio), // Size of the fan shape (adjustable)
          painter: FanPainter(),
        ),
      ),
    );
  }
}

